﻿using System;
using System.Collections;
namespace Program19
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nums1 = new int[8];
            int[] nums2 = new int[10];

            ArrayList arr = new ArrayList();
            Random rnd = new Random();

            Console.WriteLine("初始化数据A");
            while (arr.Count < 8)
            {
                int tempNum = rnd.Next(1, 100);
                if (!arr.Contains(tempNum))
                {
                    arr.Add(tempNum);
                }
            }
            for (var i = 0; i < nums1.Length; i++)
            {
                nums1[i] = (int)arr[i];
                Console.Write(nums1[i] + " ");
            }
            Console.WriteLine();
            Console.WriteLine("初始化数据B");
            while (arr.Count < 10)
            {
                int tempNum = rnd.Next(1, 100);
                if (!arr.Contains(tempNum))
                {
                    arr.Add(tempNum);
                }
            }
            for (var i = 0; i < nums2.Length; i++)
            {
                nums2[i] = (int)arr[i];
                Console.Write(nums2[i] + " ");
            }

            //合并两个数组
            int[] result = new int[18];
            //1.把nums1依次放入result[0-7]
            for (var i = 0; i < nums1.Length; i++)
            {
                result[i] = nums1[i];
            }
            //2.把nums2依次放入result[8-13]
            for (var i = 0; i < nums2.Length; i++)
            {
                result[i + nums1.Length] = nums2[i];
            }
            Console.WriteLine();
            Console.WriteLine("合并A和B结果为：");
            for (var i = 0; i < nums1.Length + nums2.Length; i++)
                Console.Write(result[i] + " ");

            //合并数组去重复的元素

        }
    }
}